
// <copyright file="DummyConnectionWrapper.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The dummy connection wrapper.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Tests.Pooling
{
    using SubhadraSolutions.Sharp.Utils.Pooling;

    /// <summary>
    /// The dummy connection wrapper.
    /// </summary>
    public sealed class DummyConnectionWrapper : IPoolItem<DummyConnection>, IConnection
    {
        #region Fields

        /// <summary>
        /// The callback.
        /// </summary>
        private ReturnAdaptedObjectToPoolDelegate<DummyConnection> _callback;

        #endregion Fields

        #region Public Properties

        /// <summary>
        /// Gets or sets the connection string.
        /// </summary>
        public string ConnectionString
        {
            get
            {
                return this.AdaptedObject.ConnectionString;
            }

            set
            {
                this.AdaptedObject.ConnectionString = value;
            }
        }

        #endregion Public Properties

        #region Properties

        /// <summary>
        /// Gets the adaptedObject.
        /// </summary>
        internal DummyConnection AdaptedObject { get; private set; }

        #endregion Properties

        #region Public Methods and Operators

        /// <summary>
        /// The close.
        /// </summary>
        public void Close()
        {
            this.Dispose();
        }

        /// <summary>
        /// The dispose.
        /// </summary>
        public void Dispose()
        {
            this._callback(this, this.AdaptedObject);
        }

        /// <summary>
        /// The set adaptedObject and callback.
        /// </summary>
        /// <param name="adaptedObject">
        /// The adaptedObject.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void SetAdaptedObjectAndCallback(DummyConnection adaptedObject, ReturnAdaptedObjectToPoolDelegate<DummyConnection> callback)
        {
            this.AdaptedObject = adaptedObject;
            this._callback = callback;
        }

        #endregion Public Methods and Operators
    }
}
